package June.object;

import java.util.Random;

public class Hero {
    //英雄数据
    private String name;
    private char gender;
    private int atk;
    private int HP;
    private int MP;

    Random ra = new Random();

    String[] skill = {
            "降龙十八掌", "天羽屠龙舞", "极地沙尘暴", "流星半月斩"
    };
    String[] state = {
            "重伤", "破甲", "致盲", "流血"
    };

    public Hero() {

    }

    public Hero(String name, char gender, int atk, int HP, int MP) {
        this.name = name;
        this.gender = gender;
        this.atk = atk;
        this.HP = HP;
        this.MP = MP;
    }

    public void PK(Hero hero) {
        Random r = new Random();
        int index = r.nextInt(skill.length);
        String hero_skill = skill[index];
        System.out.printf("%s使用" + hero_skill + "攻击了%s", this.getName(), hero.getName());
        int hurt = (this.atk / 2) - 20;
        int Crit = r.nextInt();
        int remainBoold = hero.getHP() - hurt;
        remainBoold = remainBoold < 0 ? 0 : remainBoold;

        //不同技能赋予不同负面状态
        if (hero_skill == skill[0]) {
            System.out.printf("，导致%s" + state[0], hero.getName());
            System.out.println();
        } else if (hero_skill == skill[1]) {
            System.out.printf("，导致%s" + state[1], hero.getName());
            System.out.println();
        } else if (hero_skill == skill[2]) {
            System.out.printf("，导致%s" + state[2], hero.getName());
            System.out.println();
        }else if (hero_skill==skill[3]) {
            System.out.printf("，导致%s"+state[3],hero.getName());
            System.out.println();
        }
        hero.setHP(remainBoold);
    }


    /**
     * 获取
     *
     * @return name
     */
    public String getName() {
        return name;
    }

    /**
     * 设置
     */
    public void setName(String name) {
        this.name = name;
    }

    /**
     * 获取
     *
     * @return gender
     */
    public char getGender() {
        return gender;
    }

    /**
     * 设置
     *
     * @param gender
     */
    public void setGender(char gender) {
        this.gender = gender;
    }

    /**
     * 获取
     *
     * @return atk
     */
    public int getAtk() {
        return atk;
    }

    /**
     * 设置
     *
     * @param atk
     */
    public void setAtk(int atk) {
        this.atk = atk;
    }

    /**
     * 获取
     *
     * @return HP
     */
    public int getHP() {
        return HP;
    }

    /**
     * 设置
     *
     * @param HP
     */
    public void setHP(int HP) {
        this.HP = HP;
    }

    /**
     * 获取
     *
     * @return MP
     */
    public int getMP() {
        return MP;
    }

    /**
     * 设置
     *
     * @param MP
     */
    public void setMP(int MP) {
        this.MP = MP;
    }

    public String toString() {
        return "英雄数据{姓名 = " + name + ", 性别 = " + gender + ", 攻击力 = " + atk + ", 血量 = " + HP + ", 蓝量 = " + MP + "}";
    }
}
